/*
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-11-14 10:12:04
 * @LastEditTime: 2022-11-23 14:17:49
 */
import userApi from '@/config/server/api/user.js'
import dt from '@dt/dt'
import secret from '@/common/secretCode.js'

function addUserOrg(params) {
  return userApi.orgManagement.addUserOrg.fetch(params)
}

function delUserOrg(params) {
  return userApi.orgManagement.delUserOrg.fetch(params)
}

function getpeopleList(params) {
  return userApi.orgManagement.getpeopleList.fetch(params)
}
// 角色分配
function roleGrant(params) {
  return userApi.orgManagement.roleGrant.fetch(params)
}
//用户启用禁用
function validateUser(params) {
  return userApi.orgManagement.validateUser.fetch(params)
}
//编辑人员（可编辑手机号）
function editUser(params) {
  return userApi.orgManagement.editUser.fetch(params)
}
//根据工号集合查嘉扬职级异动log
function findRankLogByWorkNos(params) {
  return userApi.orgManagement.findRankLogByWorkNos.fetch(params).then(res => {
    return res
  })
}
// 获取用户权限合集
function usUserAuth(params) {
  return userApi.orgManagement.usUserAuth.fetch(params)
}

//切换组织获取按钮code
function clickMenuCode(params) {
  params.roleId = dt.userInfo().role.roleId
  params.userId = dt.userInfo().userId
  return userApi.orgManagement.clickMenuCode.fetch(params).then(res => {
    window.sessionStorage.setItem('buttonControl', secret.Encrypt(JSON.stringify(res
      .buttonMenuCodeList)))
  })
}

// 获取职位状态与人员状态不符
function getPositionStatusUserIds(params) {
  return userApi.getPositionStatusUserIds.fetch(params).then(res => {
    return res
  })
}

function exportOrgUsers(params) {
  return userApi.exportOrgUsers.fetch(params)
}

function downloadDisableUser(params) {
  let info = {
    ...params
  }
  return userApi.orgManagement.downloadDisableUser.fetch(info)
}

function uploadDisableUser(params) {
  let info = {
    ...params
  }
  let upload = userApi.orgManagement.uploadDisableUser
  upload.setData(info)
  return upload
}

export default {
  addUserOrg,
  delUserOrg,
  getpeopleList,
  roleGrant,
  validateUser,
  editUser,
  findRankLogByWorkNos,
  usUserAuth,
  clickMenuCode,
  getPositionStatusUserIds,
  exportOrgUsers,
  downloadDisableUser,
  uploadDisableUser,
}